<template>
  <div class="view">
    <div class="form">
      <input class="name" placeholder-style="color: #777;font-weight: 300;" v-model="name" placeholder="请输入真实姓名"/>
      <input class="id-card" placeholder-style="color: #777;font-weight: 300;" v-model="idCard" placeholder="请输入身份证号"/>

      <button class="btn pass" @click="submit">认证</button>
    </div>
  </div>
</template>

<script>
  import Service from '@/utils/service'
  export default {
    data() {
      return {
        name: '',
        idCard: '',
        bikeDetails:null
      }
    },
    mounted () {

    },
    onLoad(options) {
      if(options.bikeDetails) {
        this.bikeDetails = options.bikeDetails
      }
    },
    methods: {
      submit() {
        if(this.name && this.idCard) {
          let data = {
            userId:wx.getStorageSync('userInfo').userId,
            name:this.name,
            idCard:this.idCard
          }
          Service.realName(data).then((res)=>{
            if (res.code == 200) {
              if(this.bikeDetails) {
                wx.reLaunch({
                  url: `../index/main?bikeDetails=${this.bikeDetails}`
                })
              }else {
                wx.reLaunch({
                  url: '../myself/main'
                })
              }
            }
          })
        }
      }
    }
  }
</script>

<style scoped>
  .view {
    padding: 0;
    background: #f3f6f9;
    width: 100%;
    height: 100vh;
  }
  .form {
    padding: 170px 0 0;
  }
  .name,.id-card {
    padding: 5px 20px;
    margin: 0 auto;
    width: 80%;
    height: 68px;
    line-height: 54px;
    color: #333;
    font-size: 34px;
    background: #fff;
  }
  .id-card {
    margin: 50px auto 100px;
    border: none;
  }
  .tip{
    margin: 300px auto 0;
    text-align: left;
    width: 430px;
  }
  .tip1{
    height:37px;
    font-size:28px;
    font-weight:400;
    color:#333333;
    line-height:37px;
  }
  .tip2{
    padding-top: 20px;
    font-size: 28px;
    line-height: 37px;
    color: #333333;
  }
  .tip2 span{
    color: #333333;
    text-decoration: underline;
  }
</style>
